# -*- coding: utf-8 -*-
"""
Created on Mon Oct  7 15:58:39 2020

@author: Erfan
"""

from __future__ import print_function, division # Grab some 
import numpy as np
from casadi import *

def circular_parameters():
    """ The space parameters"""
    Hr=50# The radius of the field
    Ht=2*pi # The angle which is equvalent to 360 degrees
    Hz=0.7# The depth of the soil
    Nr=6 # Number of nodes in the r-direction
    Nt=40 # Number of nodes in the theta-direction
    Nz=22 # Number of nodes in the z-direction
    dr=Hr/(Nr-1) #distance between nodes in the x-direction
    dt=Ht/Nt#angle between nodes in the theta-direction
    dz=Hz/(Nz-1) #distance between nodes in the z-direction
    Np=Nt*Nr # number of nodes in he x-y plane
    NN=Np*Nz # total number of nodes
    Nx=NN # Total number of states
    Nw=Nx # the dimension of the noise term which is equal to the number of states
    Ny=Nx #
    Nv=Ny
    return Nr,Nt,Nz,dr,dt,dz,Np,NN,Nx,Nw,Ny,Nv


def time_parameters():
    """ The time parameters"""
    DeltaT =720  # Time step(The MHE sampling time i.e the time after which the measurement is obtained expressed in seconds)    
    Tsim =720*1200 # Simulation time
    Nsim = int(Tsim/DeltaT) # Number of times simulation is done.
    return DeltaT,Nsim


ThetaS=np.loadtxt('ThetaSn.txt')
ThetaR=np.loadtxt('ThetaRn.txt')
Ks=np.loadtxt('Ksn.txt')
Alpha=np.loadtxt('Alphan.txt')
n=np.loadtxt('Nn.txt')


def parameter_node(i):
    pars={}
    pars['thetaR']= ThetaR[i]
    pars['thetaS']=ThetaS[i]
    pars['alpha']=Alpha[i]
    pars['n']=n[i]
    pars['m']=1-1/pars['n']
    pars['Ks']=Ks[i]
    pars['neta']=0.5
    pars['Ss']=0.00001
    
    return pars
